#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <sys/sem.h>

enum{CHAR_TYPE=0,INT_TYPE,STR_TYPE};

struct item_1Byte{
	unsigned char name[ETOPSHM_STR_LEN];
	unsigned char v;
};
struct item_4Byte{
	unsigned char name[ETOPSHM_STR_LEN];
	unsigned int v;
};
struct item_string{
	unsigned char name[ETOPSHM_STR_LEN];
	unsigned char v[ETOPSHM_STR_LEN];
};

struct __data{
	struct item_1Byte c[ETOPSHM_ITEM_CNT];
	struct item_4Byte i[ETOPSHM_ITEM_CNT];
	struct item_string s[ETOPSHM_ITEM_CNT];
};

typedef union _data{
	unsigned char block[ETOPSHM_BLOCK_LEN];
	struct __data d;
}ETOPSHM_T;

void etopshm_init(void);
void set_all(ETOPSHM_T *etopshmaddr,char *name,void *value,int i,int type);
void etopshm_set(int type,char *name,void *value);
int etopshm_get(int type,char *name,void *value);
void etopshm_wipe(void);
void etopshm_dumpall(void);
void etopshm_sem_init(int key);
int etopshm_sem_p(void);
int etopshm_sem_v(void);
